package com.mingdong.first.diedaiqi;

import java.util.ArrayList;
import java.util.List;

public class ConcreteMyeeaa {

	private List<Object> list = new ArrayList<Object>();
	
	public void addObj(Object obj){
		list.add(obj);
	}
	public void removeObh(Object obj){
		list.remove(obj);
	}

	public List<Object> getList() {
		return list;
	}

	public void setList(List<Object> list) {
		this.list = list;
	}
	
	public MyIterater createIterater(){
		return new ConcreteIterater();
	}
	
	class ConcreteIterater implements MyIterater{

		private int cursor;
		
		public void first() {
			cursor = 0;
		}

		public void last() {
			cursor = list.size() - 1;
		}

		public Boolean hasNext() {

			if(cursor < list.size()){
				return true;
			}
			return false;
		}

		public Object getCurrentObj() {
			
			return list.get(cursor);
		}

		public Boolean isFirst() {

			if(cursor == 0){
				return true;
			}
			return false;
		}

		public Boolean isLast() {
			if(cursor == list.size() - 1){
				return true;
			}
			return false;
		}	
		public void next(){
			if(cursor < list.size()){
				cursor ++;
			}
		}
		
	}
}
